#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <linux/fb.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <stdlib.h>

#include <display_manager.h>
#include <font_manager.h>
#include <ui_manager.h>



int main(int argc, char **argv)
{
	if(argc != 2)
	{
		printf("User : %s <font_file> \n",argv[0]);
		return -1;
	}
	
	PDispBuffer ptBuffer;
	int error;
	Button tButton;
	Region tRegion;
	InputEvent tEvent;
	int DeviceSign;
	int ret;
	
	InputDev_Register();
	InputDevice_Init();
	DisplayInit();
	SelectDefaultDisplay("frambuffer");
	InitDefaultDisplay();	
	ptBuffer = Get_DispBuffer();
	Fonts_Init();
	
	error = Fonts_Select("freetype",argv[1]);
	if(error)
	{
		printf("Fonts_Select error\n");
		return -1;
	}
	
	tRegion.iHeigh   = 100;
	tRegion.iWidth   = 400;
	tRegion.iLeftUpx = 200;
	tRegion.iLeftUpY = 200;
	InitButton(&tButton , "xiaota" , &tRegion , NULL , NULL );
	tButton.OnDraw(&tButton , ptBuffer);
	while(1)
	{
		ret = GetInputEvent(&tEvent);
		if(!ret)
		{
			printf("GetInputEvent err\n");
			return -1;
		}
		DeviceSign = tEvent.iType;
		if(DeviceSign == INPUT_TYPE_TOUCH)
		{
			if(tEvent.iPressure)
			{
				tButton.OnPressed(&tButton , ptBuffer , NULL);
				printf("iPressure = %d\n" , tEvent.iPressure);
				sleep(1);
			}
		}
	}
	return 0;	
}


